import { createRouter, createWebHashHistory } from 'vue-router'
import Layout from '@/layout'

export const constantRoutes = [
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login'),
    hidden: true,
  },
  {
    path: '/403',
    name: '403',
    component: () => import('@/views/403'),
    hidden: true,
  },
  {
    path: '/404',
    name: '404',
    component: () => import('@/views/404'),
    hidden: true,
  },
]
export const asyncRoutes = [
  {
    path: '/',
    component: Layout,
    redirect: '/index',
    meta: {
      title: '首页',
      icon: 'home-4-line',
      affix: true,
    },
    children: [
      {
        path: 'index',
        name: 'Index',
        component: () => import('@/views/index'),
        meta: {
          keepAlive: true,
          title: '首页',
          icon: 'home-4-line',
          affix: true,
        },
      },
    ],
  },
  // 工作台
  {
    path: '/workbench',
    component: Layout,
    redirect: '/workbench/userIndex',
    alwaysShow: true,
    meta: {
      title: '工作台',
      icon: 'apps-line',
    },
    children: [
      {
        path: 'userIndex',
        name: 'userIndex',
        component: () => import('@/views/workbench/userIndex'),
        meta: {
          title: '个人首页',
          icon: 'account-pin-circle-line',
        },
      },
      {
        path: 'editUserIndex',
        name: 'editUserIndex',
        component: () => import('@/views/workbench/editUserIndex'),
        hidden: true,
        meta: {
          title: '编辑工作台',
          icon: 'edit-line',
        },
      },
      {
        path: 'pending',
        name: 'Pending',
        component: () => import('@/views/workbench/Pending'),
        meta: {
          title: '待处理',
          icon: 'bar-chart-horizontal-line',
        },
      },
      {
        path: 'Processed',
        name: 'Processed',
        component: () => import('@/views/workbench/Processed'),
        meta: {
          title: '已处理',
          icon: 'remixicon-line',
        },
      },

      {
        path: 'detailed',
        name: 'detailed',
        component: () => import('@/views/workbench/detailed'),
        hidden: true,
        meta: {
          title: '详细',
          icon: 'remixicon-line',
        },
      },
      {
        path: 'sortList',
        name: 'sortList',
        component: () => import('@/views/workbench/sortList'),
        meta: {
          title: '分类列表',
          icon: 'table-2',
        },
      },
      {
        path: 'businessList',
        name: 'businessList',
        component: () => import('@/views/workbench/businessList'),
        hidden: true,
        meta: {
          title: '业务列表',
          icon: 'remixicon-line',
        },
      },
      {
        path: 'startFlow',
        name: 'startFlow',
        component: () => import('@/views/workbench/startFlow'),
        hidden: true,
        meta: {
          title: '发起流程',
          icon: 'remixicon-line',
        },
      },
    ],
  },

  {
    path: '/flow',
    component: Layout,
    redirect: '/flow/flowList',
    meta: {
      title: '流程模块',
      icon: 'anticlockwise-2-line',
    },
    children: [
      {
        path: 'flowList',
        name: 'flowList',
        component: () => import('@/views/flow/list'),
        meta: {
          title: '流程管理',
          icon: 'file-copy-2-line',
        },
      },
      {
        path: 'flowEdit',
        name: 'flowEdit',
        component: () => import('@/views/flow/edit'),
        hidden: true,
        meta: {
          title: '编辑流程',
          icon: 'edit-line',
        },
      },
    ],
  },
  {
    path: '/form',
    component: Layout,
    redirect: '/form/formList',
    meta: {
      title: '表单模块',
      icon: 'stack-line',
    },
    children: [
      {
        path: 'formList',
        name: 'formList',
        component: () => import('@/views/form/list'),
        meta: {
          title: '表单管理',
          icon: 'table-alt-line',
        },
      },
      {
        path: 'formEdit',
        name: 'formEdit',
        component: () => import('@/views/form/edit'),
        hidden: true,
        meta: {
          title: '表单编辑',
          icon: 'edit-line',
        },
      },
    ],
  },
  {
    path: '/report',
    component: Layout,
    redirect: '/report/reportList',
    meta: {
      title: '报表模块',
      icon: 'file-copy-2-line',
    },
    children: [
      {
        path: 'reportList',
        name: 'reportList',
        component: () => import('@/views/report/list'),
        meta: {
          title: '报表管理',
          icon: 'file-copy-2-line',
        },
      },
      {
        path: 'reportEdit',
        name: 'reportEdit',
        component: () => import('@/views/report/edit'),
        hidden: true,
        meta: {
          title: '修改报表',
          icon: 'edit-line',
        },
      },
      {
        path: 'readReport',
        name: 'readReport',
        component: () => import('@/views/report/readReport'),
        hidden: true,
        meta: {
          title: '预览报表',
          icon: 'eye-line',
        },
      },
    ],
  },

  {
    path: '/system',
    component: Layout,
    redirect: '/system/homepageList',
    meta: {
      title: '系统模块',
      icon: 'dashboard-line',
    },
    children: [
      {
        path: 'homepageList',
        name: 'homepageList',
        component: () => import('@/views/homepage/list'),
        meta: {
          title: '自定义首页',
          icon: 'table-line',
        },
      },
      {
        path: 'homepageEdit',
        name: 'homepageEdit',
        component: () => import('@/views/homepage/edit'),
        hidden: true,
        meta: {
          title: '编辑页面',
          icon: 'edit-line',
        },
      },

      {
        path: 'dataComponentList',
        name: 'dataComponentList',
        component: () => import('@/views/dataComponent/list'),
        meta: {
          title: '数据组件',
          icon: 'basketball-line',
        },
      },

      {
        path: 'organize',
        name: 'organize',
        component: () => import('@/views/system/organize'),
        meta: {
          title: '组织架构',
          icon: 'dashboard-line',
        },
      },
      {
        path: 'stemDictionary',
        name: 'stemDictionary',
        component: () => import('@/views/system/stemDictionary'),
        meta: {
          title: '数据字典',
          icon: 'book-2-line',
        },
      },
    ],
  },
  // {
  //   path: '/error',
  //   name: 'Error',
  //   component: Layout,
  //   redirect: '/error/403',
  //   meta: {
  //     title: '错误页',
  //     icon: 'error-warning-line',
  //   },
  //   children: [
  //     {
  //       path: 'newPage',
  //       name: 'newPage',
  //       component: () => import('@/views/newPage'),
  //       meta: {
  //         title: '新页面',
  //         icon: 'remixicon-line',
  //       },
  //     },
  //     {
  //       path: '403',
  //       name: 'Error403',
  //       component: () => import('@/views/403'),
  //       meta: {
  //         title: '403',
  //         icon: 'error-warning-line',
  //       },
  //     },
  //     {
  //       path: '404',
  //       name: 'Error404',
  //       component: () => import('@/views/404'),
  //       meta: {
  //         title: '404',
  //         icon: 'error-warning-line',
  //       },
  //     },
  //   ],
  // },
  {
    path: '/*',
    redirect: '/404',
    hidden: true,
  },
]
const router = createRouter({
  history: createWebHashHistory(),
  routes: constantRoutes,
})
export default router
